﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FxCopContrib.TestHarness
{
    internal static class TestFrameworkHelpers
    {
        internal static MethodBase FindTestMethod()
        {
            StackTrace trace = new StackTrace();
            foreach (StackFrame frame in trace.ToEnumerable())
            {
                MethodBase method = frame.GetMethod();
                bool isTestMethod = method.GetCustomAttributes(typeof(TestMethodAttribute), true).Any();
                if (isTestMethod)
                {
                    return method;
                }
            }
            return null;
        }
    }
}
